
	Ext.namespace("panel.environment");

	/**
	 * Environment:
	**/
	panel.environment = {
		
		_init: false,

		init: function() {
			
			if( panel.environment._init ) {
				return; }
				
			panel.environment._init = true;
			panel.environment.makeBindings();
									
			panel.console.time.log("Env:Autoload");
			
			if( panel.workspace.autoload instanceof Function ) {
				panel.workspace.autoload(); }
				
			panel.console.time.log("Env:Autoload");
		
		},
				
		makeBindings: function() {
		
			// Check environment status
			window.setInterval( panel.environment.status.check, 5000 );
			
			/* {% if $environment.state == "local" %} */
			window.setInterval( function() {
				
				panel.console.logDomElements();
				
			}, 60000);
			/* {% /if %} */
			
			// Try to cleanup
			Ext.EventManager.on(window, "unload", function() { 
					
				try {

					document.body.addClass("e_loading");
					
				} catch(e) {} 
					
			});
			
		}	// function
			
	};	// enviroment
	
	panel.environment.status = {
		
		_latest  : null,
		_data    : {% $environment.status|@json_encode %},
		_message : null,
		
		check: function() {
			
			

		}
		
	};
	